#include "../test_type.h"
#include "../../src/stream/StringTools.h"
#include "../../src/debug/debug.h"
#include <assert.h>
#include <iostream>

using namespace std;
USE_LIBTOOLS;

#define TEST_MAX_COUNT 1000000

#ifdef TEST_STRING
int main()
{
	string param(4097, '1');
	string str = format("%s|%s", "test1", "test2");
	assert(str == string("test1|test2"));
	cout << str << endl;

	str = format("%s", param.data());
	assert(str.size() == 4097);

	string str2 = format_s(10, "%s|%s", "1234567", "890"); // failed!
	assert(str2.empty() == true);
	cout << str2 << endl;

	string str3 = "1,2,";
	vector<string> strs;
	split(str3, ',', strs);
	assert(strs.size() == 2);
	PRINT_CONT(cout, strs.begin(), strs.end());

	string str4 = "1,2";
	split(str4, ',', strs);
	assert(strs.size() == 2);
	PRINT_CONT(cout, strs.begin(), strs.end());

	string str5 = "1,,";
	split(str5, ',', strs);
	assert(strs.size() == 1);
	PRINT_CONT(cout, strs.begin(), strs.end());

	string str6 = "";
	split(str6, ',', strs);
	assert(strs.size() == 0);
	PRINT_CONT(cout, strs.begin(), strs.end());

	string str7 = ",";
	split(str7, ',', strs);
	assert(strs.size() == 0);
	PRINT_CONT(cout, strs.begin(), strs.end());

	return 0;
}

#endif // TEST_STRING
